package com.small.nacos.common.utils;

/**
 * @Author zhoujin
 * @Date 2022/11/13 13:53
 */
public class ThreadUtils {
    /**
     * 通过核数，计算适当的线程数。
     * @param threadMultiple
     * @return
     */
    public static int getSuitableThreadCount(int threadMultiple) {
        final int coreCount = Runtime.getRuntime().availableProcessors();
        int workerCount = 1;
        while (workerCount < coreCount * threadMultiple) {
            workerCount <<= 1;
        }
        return workerCount;
    }
}
